from app import db

class RecipeFood(db.Model):
    __tablename__ = 'recipe_food'  # 连接表

    recipe_id = db.Column(db.Integer, db.ForeignKey('recipes.recipe_id'), primary_key=True)  # 食谱ID，外键
    food_id = db.Column(db.Integer, db.ForeignKey('foods.food_id'), primary_key=True)  # 食物ID，外键
    quantity = db.Column(db.Float)  # 食物的数量（例如克数）
    instruction = db.Column(db.Text)  # 制作该食物的步骤或说明

    # recipe = db.relationship('Recipe', back_populates='foods')
    # food = db.relationship('Food', back_populates='recipes')

    def __repr__(self):
        return f'<RecipeFood {self.recipe_id} - {self.food_id}>'
